<template>
	<view class="sendcity">
		<u-navbar title="切换城市"></u-navbar>
		<view class="sendcity-history">
			<view>历史</view>
			<view class="sendcity-history-name" @click="cityClick('',0)">禹州</view>
		</view>
		<view class="sendcity-li" v-for="(item,index) in cityList" :key="index" @click="cityClick(item)">
			{{item.CODETB01CA01}}
		</view>
		<!-- <u-index-list :scrollTop="scrollTop">
			<view v-for="(item, index) in indexList" :key="index">
				<u-index-anchor :index="item" />
				<view class="list-cell sendcity-li" v-for="(items, indexs) in cityList" :key="indexs" @click="cityClick(items)">
					{{items.CODETB01CA01}}
				</view>
			</view>
		</u-index-list> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cityList: [],
				// scrollTop: 0,
				// indexList: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U","V", "W", "X", "Y", "Z"]

			}
		},
		// onPageScroll(e) {
		// 	this.scrollTop = e.scrollTop;
		// },
		onShow() {
			this.querycity()
		},
		methods: {
			cityClick(item,type) {
				if(type==0){
					item={
						CODETB01CA00: "411000",
						CODETB01CA01: "许昌市",
						CODETB01CA02: "410000",
						CODETB01CA03: "1",
						CODETB01ID: "161"
					}
				}
				var str = JSON.stringify(item)
				uni.setStorageSync('city', str);
				uni.setStorageSync('tj', 'tj');
				uni.navigateBack()
			},
			querycity() {
				uni.showLoading({
					title: '加载中...',
					mask: true
				});
				uni.request({
					url: this.baseUrl + '/code/condtb01/selecList',
					method: 'POST',
					dataType: 'json',
					data: {

					},
					success: (res) => {
						console.log(res);
						uni.hideLoading();
						if (res.data.code == 200) {
							this.cityList = res.data.data
						} else {
							uni.showToast({
								title: res.data.message,
								duration: 5000,
								icon: 'none',
							});
						}
					},
					fail: (res) => {
						uni.hideLoading();
						uni.showToast({
							title: res.data.message,
							duration: 5000,
							icon: 'none',
						});
					}
				});
			}
		}
	}
</script>

<style scoped>
	.sendcity {
		min-height: 100vh;
		width: 100vw;
		background-color: #efeff4;
	}

	.sendcity-history {
		padding: 20rpx 0 20rpx 40rpx;
		background-color: #FFF;
		color: #333;
		font-weight: 600;
	}

	.sendcity-history-name {
		width: 200rpx;
		line-height: 55rpx;
		text-align: center;
		background: #efeff4;
		margin-top: 20rpx;
		border-radius: 7rpx;
		font-weight: 400;
	}

	.sendcity-li {
		height: 80rpx;
		line-height: 80rpx;
		color: #333;
		/* font-size: 28rpx; */
		background-color: #FFF;
		padding-left: 40rpx;
	}

	.sendcity-li+.sendcity-li {
		border-top: 2rpx solid #e3e3e3;
	}
</style>
